//
//  EdHttp.h
//  短信
//
//  Created by xiaocao on 2018/5/29.
//  Copyright © 2018年 Edubrain. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface EdHttp : NSObject



/**
 *  get请求
 *
 *  @param url     请求URL
 *  @param params  普通的请求参数
 *  @param success 请求成功后的回调
 *  @param failure 请求失败后的回调
 */

+ (void)get:(NSString *)url
     params:(id)params
   progress:(void (^)(id downloadProgress))progress
    success:(void (^)(id responseObject))success
    failure:(void (^)(NSError *error))failure;


/**
 *  post请求
 *
 *  @param url     请求URL
 *  @param params  普通的请求参数
 *  @param success 请求成功后的回调
 *  @param failure 请求失败后的回调
 */

+ (void)post:(NSString *)url
      params:(id)params
    progress:(void (^)(id uploadProgress))progress
     success:(void (^)(id responseObject))success
     failure:(void (^)(NSError *error))failure;




/**
 *  文件上传
 *
 *  @param url     请求URL
 *  @param params  普通的请求参数
 *  @param files   文件参数(里面都是HWHttpFile模型)
 *  @param success 请求成功后的回调
 *  @param failure 请求失败后的回调
 */
+ (void)upLoad:(NSString *)url
        params:(id)params
         files:(NSArray *)files
      progress:(void (^)(id uploadProgress))progress
       success:(void (^)(id responseObject))success
       failure:(void (^)(NSError *error))failure;

@end



@interface HttpFile : NSObject

/** 文件参数名 */
@property (nonatomic, copy) NSString *name;
/** 文件数据 */
@property (nonatomic, strong) NSData *data;
/** 文件类型 */
@property (nonatomic, copy) NSString *mimeType;
/** 文件名 */
@property (nonatomic, copy) NSString *filename;


+ (instancetype)fileWithName:(NSString *)name
                        data:(NSData *)data
                    mimeType:(NSString *)mimeType
                    filename:(NSString *)filename;

@end
